package com.heu.blood.statistic.controller;

import com.heu.blood.common.aop.ControllerLogAnnotation;
import com.heu.blood.common.utils.PageUtils;
import com.heu.blood.common.utils.R;
import com.heu.blood.statistic.entity.BloodUsagePurpose;
import com.heu.blood.statistic.entity.BloodUsagePurposeFirstVo;
import com.heu.blood.statistic.entity.EchartItem;
import com.heu.blood.statistic.service.BloodUsagePurposeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * @author bearH
 * @date 2023-09-07 15:43
 */
@RestController
@RequestMapping("statistic/bloodusagepurpose")
public class BloodUsagePurposeController {
    @Autowired
    private BloodUsagePurposeService bloodUsagePurposeService;

    @ControllerLogAnnotation(module = "用血用途统计", operate = "分页查询用血用途统计")
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = bloodUsagePurposeService.queryPage(params);
        return R.ok().put("page", page);
    }

    @RequestMapping("/list2")
    public BloodUsagePurpose list2(@RequestParam Map<String, Object> params){
        PageUtils page = bloodUsagePurposeService.queryPage(params);
        return null;
    }

    @ControllerLogAnnotation(module = "用血用途统计", operate = "各用血用途统计")
    @RequestMapping("/byPurpose")
    public R getBloodUsageByPurpose() {
        BloodUsagePurposeFirstVo result = bloodUsagePurposeService.getBloodUsageByPurpose();
        return R.ok().put("data", result);
    }

    @ControllerLogAnnotation(module = "用血用途统计", operate = "按用途编号统计")
    @RequestMapping("/detailByPurpose")
    public R getDetailByPurpose(@RequestParam String usageCode) {
        Map<String, List<EchartItem>> result = bloodUsagePurposeService.getBloodTypeAndDepartmentUsageByPurpose(usageCode);
        return R.ok().put("data",result);
    }

}
